home *** CD-ROM | disk | FTP | other *** search
- /*
-
- [DSKEL-WHO v_._] Who [Deluxe] By The Skeleton [__-__-__]
- |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
- | # | LOGON | HANDLE | ACTiViTY | FiLENAME SiZE |
- |===|=======|======================|====================|=====================|
- | 1 | 19:44 | The Skeleton | Downloading | NewFile.dms 1358868 |
- |---|-------|----------------------|--------------------|---------------------|
- | 2 | 19:44 | The Skeleton | Uploading | NewFile.dms 358868 |
- |---|-------|----------------------|--------------------|---------------------|
- | 3 | : | Awaiting a call | | |
- |---|-------|----------------------|--------------------|---------------------|
- | 4 | : | Awaiting a call | | |
- |---|-------|----------------------|--------------------|---------------------|
- | 5 | : | Awaiting a call | | |
- `-----------------------------------------------------------------------------'
-
- */
- //**********************
- //***** Includes *****
- //**********************
-
- #include <proto/all.h>
- #include <stdio.h>
- #include <exec/memory.h>
-
- #include <string.h>
- #include <tempest/headers.h>
-
- //********************************
- //***** Structures/Defines *****
- //********************************
-
-
- struct MyMessage
- {
- struct Message Msg;
- struct User User;
- char text[255],
- text1[255];
- int car,Value,Data;
- long LongValue;
- int IntValue;
- };
-
- struct User User;
- struct MsgPort *MyPort = NULL;
- struct MyMessage *msg;
- struct Down_Load Down_Load;
- struct DownLoad_Status DownLoad_Status;
-
- struct node_info nody;
-
- void CloseStuff();
- void pl(char outstring[]);
- void RIPIT(char *,char *);
- int DOORIO();
- int Loadnody(int node);
- //******************************
- //***** Global Variables *****
- //******************************
-
- int EXIT_FLAG, DOOR_DATA, DOOR_CAR, DOOR_VALUE, DOOR_VALUE1 = 0,
- Result,Error,first = 0;
- char MyName[255],st[100],DOOR_MSG[255],DOOR_MSG1[255];
-
- //******************
- //***** Main *****
- //******************
-
- void main(int argc,char *argv[])
- {
- struct FileInfoBlock *FBlock;
- struct FileLock *FLock;
- char string[255],string2[255];
- char Handle[40],Location[40],Activity[30],Time[15],Filename[15],Filesize[15];
- int file,Position,stat,count=0,NODES,NODE;
- register i;
-
- if(!DoorStart(argv[1])) { PutStr("[os2] Tempest Door\n"); exit(0); }
-
- if(!User.NFlags1 & NF1_ViewNodeLists) CloseStuff();
-
- //********************************
- //***** Load Internal.Data *****
- //********************************
-
- NODE = atoi(argv[1]);
- stat=Loadnody(NODE);
- if(stat==0)
- {
- pl("NodeInfo File Not Found!\r\n");
- CloseStuff();
- }
- NODES = nody.SystemDataInfo->NumberOfLines + 1;
-
- pl("\f.-----------------------------------------------------------------------------.\r\n");
- pl("| # | LoGoN | HANDLE | ACTiViTY | FiLENAME SiZE |\r\n");
-
- i=1;
- do
- {
- if(CTRLC())
- {
- pl("Aborting Who Display!\r\n");
- CloseStuff();
- }
- stat=Loadnody(i);
- if(stat==0) setmem(&nody,sizeof(struct node_info),NULL);
- strcpy(Filename," ");
- strcpy(Filesize," ");
-
- //***********************
- //***** Uploading *****
- //***********************
- if(*nody.AN== 58) // Only If they are uploading!
- {
- sprintf(string,"%s",nody.NodeDataInfo->TempULWorkPath);
- if((FLock =(struct FileLock *)Lock(string,ACCESS_READ))==NULL) CloseStuff();
- if((FBlock=(struct FileInfoBlock *)AllocMem((long)sizeof(struct FileInfoBlock),MEMF_CHIP)) == NULL)
- {
- UnLock((BPTR)FLock);
- CloseStuff();
- }
- Examine((BPTR)FLock,FBlock);
- while ((ExNext((BPTR)FLock,FBlock))!=0)
- {
- if((FBlock->fib_DirEntryType) <0)
- {
- strcpy(Filename,FBlock->fib_FileName);
- sprintf(Filesize,"%ld",FBlock->fib_Size);
- break;
- }
- }
- UnLock((BPTR)FLock);
- FreeMem(FBlock,sizeof(struct FileInfoBlock));
- }
-
- //********************************
- //***** Downloading Checks *****
- //********************************
-
- if(*nody.AN==18) // Only If they are Downloading!
- {
- sprintf(string, "NODE:Download_File_List_Node#%d",i);
- sprintf(string2,"NODE:Download_File_Status_Node#%d",i);
- file=Open(string2,MODE_OLDFILE);
- if(file==0)
- {
- file=Open(string,MODE_OLDFILE); // Single Downloading
- if(file!=0) Read(file,(char *)&Down_Load, sizeof(struct Down_Load));
- }
- else
- {
- do
- {
- count++;
- stat=Read(file,(char *)&DownLoad_Status, sizeof(struct DownLoad_Status));
- }
- while(stat > 0);
- Close(file);
- file=Open(string,MODE_OLDFILE);
- count--;
- Position=sizeof(struct Down_Load) * count;
- Seek(file,Position,OFFSET_BEGINNING);
- Read(file,(char *)&Down_Load, sizeof(struct Down_Load));
- }
- Close(file);
- strcpy(string,Down_Load.File);
- RIPIT(string,string2);
- strcpy(Filename,string2);
- sprintf(Filesize,"%ld",Down_Load.Bytes);
- count=0;
- }
-
- //**************************
- //***** Final Output *****
- //**************************
-
- strcpy(Handle,nody.UserInfo->Name);
- if((*nody.hide==1)&&(User.Security!=255)&&(User.Name[0]!=NULL))
- {
- if(nody.UserInfo->Slot_Number==1) Handle[0]=NULL;
- else strcpy(Handle,"[ Hiding From Display ]");
- strcpy(Location," ");
- strcpy(Filename," ");
- }
- if(Handle[0]!=NULL)
- {
- sprintf(string,"%s",ctime(&nody.UserInfo->Time_Last_Connect));
- strmid(string,Time,12,5);
- strcpy(Location,nody.UserInfo->City);
- strcpy(Activity,nody.activity);
- pl("|---|-------|---------------------|--------------------|----------------------|\r\n");
- if(nody.NodeDataInfo->LocalMode==0) sprintf(string2,"%2d",i);
- else strcpy(string2," V");
- sprintf(string,"|%2s | %5s | %-20.20s| %-19s| %-12.12s %7s |\r\n",
- string2,Time,Handle,Activity,Filename,Filesize);
- pl(string);
- }
- i++;
- }
- while(i<NODES);
- pl("`-----------------------------------------------------------------------------'\r\n\r\n");
- CloseStuff();
- }
-
-
-
-
- //************************
- //***** Load Nody ******
- //************************
-
- int Loadnody(int node)
- {
- char string[50];
- register int y;
- int file;
- sprintf(string,"Node:NodeInfo_%d",node);
- for(y=1;y<3;y++)
- {
- file=Open(string,MODE_OLDFILE);
- if(file!=0)
- {
- Read(file,(char *)&nody,sizeof(struct node_info));
- Close(file);
- return(1);
- }
- }
- return(0);
- }
-
-
-
-
-
- //*******************
- //***** Ripit *****
- //*******************
-
- void RIPIT(char path[100],char fname[100])
- {
- int x,y,len;
- char string[255],string1[255],string3[255],string4[255];
- /* to get the reverse read of the file name */
- len=strlen(path);
- x=len-1;
- y=0;
- while(x>=0)
- {
- if(path[x]==':' || path[x]=='/') goto got;
- string[y] = path[x];
- x--;
- y++;
- }
- if(y==0) return; /* Unknown (0)? */
- got:
- string[y]='\0';
- /* reverse read to finish the line to get the path */
- y=0;
- while(x>=0)
- {
- string3[y] = path[x];
- x--;
- y++;
- }
- string3[y]='\0';
- /* flip the path around */
- len=strlen(string3);
- x=len-1;
- y=0;
- while(x>=0)
- {
- string4[y] = string3[x];
- x--;
- y++;
- }
- string4[y]='\0';
- len=strlen(string);
- /* flip the filename around */
- x=len-1;
- y=0;
- while(x>=0)
- {
- string1[y] = string[x];
- x--;
- y++;
- }
- string1[y]='\0';
- strcpy(fname,string1);
- strcpy(path,string4);
- }
-
-
-
- //*************************
- //***** Close Stuff *****
- //*************************
-
- void CloseStuff()
- { DOOR_DATA=99; strcpy(DOOR_MSG,'\0'); DOORIO();
- while(msg=(struct MyMessage *)GetMsg(MyPort)) ReplyMsg((struct Message *)msg);
- if(MyPort) DeletePort(MyPort);
- exit(0); }
-
- //********************
- //***** DoorIO *****
- //********************
-
- int DOORIO()
- {
- struct MsgPort *HisPort;
- struct MyMessage message;
- int UPDATE;
- if(EXIT_FLAG) return 0;
- UPDATE=0;
- HisPort = FindPort(st);
- if(HisPort!=NULL)
- {
- message.Msg.mn_Node.ln_Type = NT_MESSAGE;
- message.Msg.mn_Length = sizeof(message);
- message.Msg.mn_ReplyPort = MyPort;
- if(first)CopyMem(&User,&message.User,sizeof(struct User));
- message.car = 0;
- message.Data = DOOR_DATA;
- message.Value = DOOR_VALUE;
- message.IntValue = DOOR_VALUE1;
- strcpy(message.text,DOOR_MSG);
- strcpy(message.text1,DOOR_MSG1);
- PutMsg((struct MsgPort *)HisPort,(struct Message *)&message);
- Wait(1 << MyPort->mp_SigBit);
- GetMsg(MyPort);
- DOOR_DATA = message.Data;
- DOOR_VALUE = message.Value;
- DOOR_VALUE1 = message.IntValue;
- strcpy(DOOR_MSG,message.text);
- strcpy(DOOR_MSG1,message.text1);
- CopyMem(&message.User,&User,sizeof(struct User));
- first=1;
- UPDATE=0;
- if(message.car) EXIT_FLAG=1;
- }
- return 0;
- }
-
- //************************
- //***** Door Start *****
- //************************
-
- DoorStart(char node[])
- {
- struct MsgPort *HisPort;
- EXIT_FLAG = 0;
- sprintf(st,"%s:TEMPEST_DOOR",node);
- HisPort = FindPort(st);
- if(HisPort==NULL) return (FALSE);
- sprintf(MyName,"%s:DOOR_PORT",node);
- MyPort = CreatePort(MyName,0L);
- if(MyPort==NULL)
- {
- PutStr("Cant open port");
- return(int)FALSE;
- }
- DOORIO();
- return (int)TRUE;
- }
-
- //*****************************
- //***** PL (Print Line) *****
- //*****************************
-
- void pl(char outstring[])
- { DOOR_DATA=1; strcpy(DOOR_MSG,outstring); DOORIO(); }
-
-
- //*************************
- //***** CTRLC CHECK *****
- //*************************
-
- int CTRLC(void)
- {
- DOOR_DATA=73;
- DOORIO();
- return(DOOR_VALUE);
- }
-
-